﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Dict.Blo;
using Dict.DataModel;

public class PlayerLevelUp : MonoBehaviour
{
    public List<UI.ItemValue> growItems;
    public List<LevelupUnlockItem> unlockItems;

    AudioClip ac;

    public void SetLevelUp(int from, int to)
    {
        GetComponent<UI.PageTweener>().Play();

        growItems[0].currentLable.text = from.ToString();
        growItems[0].nextLable.text = to.ToString();
        
        TableUserExp userExpTo = DictUserExpBlo.GetTableUserExp(to);

        int addstamina = 0;
        int addenergy = 0;
        if (userExpTo != null)
        {
            addstamina = userExpTo.stamina;
            addenergy = userExpTo.energy;
        }

        //体力
        growItems[1].currentLable.text = (StaticData.playerData.Stamina - addstamina).ToString();
        growItems[1].nextLable.text = (StaticData.playerData.Stamina).ToString();

        //耐力
        growItems[2].currentLable.text = (StaticData.playerData.Energy - addenergy).ToString();
        growItems[2].nextLable.text = (StaticData.playerData.Energy).ToString();

        //解锁新功能
        List<TableModule> list = Dict.DictModuleBlo.GetThreeModulesNearLevel(to);
        for (int i = 0; i < list.Count; i++)
        {
            unlockItems[i].SetUnlockItem(list[i], to);
        }

        //音效
        AudioManager.Instance.PlayUIAudio("levelUp");
    }

    public void OnMaskClick()
    {
        gameObject.SetActive(false);
        if (GuideManager.Instance != null)
        {
            GuideManager.Instance.OnLevelUp();
        }
        StaticData.funcNavKit.OnLevelUp();

    }
}


